//app.js
App({
  onLaunch: function () {
    var that=this;
    wx.login({
      success: function (res) {
        if (res.code) {
          //发起网络请求
          wx.request({
            url: that.globalData.apiUrl + "/user/login",
            data: {
              code: res.code
            },
            success: function (res1) {
              // openid
              that.globalData.openid = JSON.parse(res1.data).openid;
              console.log(that.globalData.openid);
            }
          })
        } else {
          console.log('获取用户登录态失败！' + res.errMsg)
        }
      }
    });

    wx.getUserInfo({
      success: function (res) {
        that.globalData.userInfo = res.userInfo;
      },
      fail: function () {
        // fail
        console.log("获取失败！")
      },
      complete: function () {
        // complete
        // console.log("获取用户信息完成！")
      }
    })
  },
  globalData: {
    userInfo: null,
    openid:null,
    // apiUrl:"https://wxapi.hotapp.cn/proxy/?appkey=hotapp11377340&url=http://119.29.8.199/aoqianwx/aoqianwxapi/public",
    apiUrl: "https://wxapi.hotapp.cn/proxy/?appkey=hotapp11377340&url=http://119.29.8.199/tianjiao/tianjiaoapi/public/index.php",
    resourceUrl: "http://119.29.8.199/tianjiao/Admin/"
  }
})